# 1-导包
import pymysql

# 2-创建数据库连接
conn = pymysql.connect(host="121.43.169.97", user="student", port=3306, password="P2P_student_2022",
                       database="czbk_member", charset="utf8")

# 3-获取连接的游标
cursor = conn.cursor()

# 定义sql语句
sql = "SELECT * from mb_member limit 1;"

print(sql.split(" ")[0])  # 切割字符串
print(sql.lower())  # 将字符串转为小写

# 4-执行sql语句
cursor.execute(sql)

# 输出查询结果
print(cursor.fetchall())

# 5-提交执行的结果
conn.commit()

# 6-关闭游标
cursor.close()

# 7-关闭连接
conn.close()
